<!DOCTYPE html>
<html>
<head>
    <title>身体不适管理</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="木兰湾管理系统">
    <script type="text/javascript" src="../../static/include/header-css.js"></script>
    <script type="text/javascript">

    </script>
</head>
<body>
<div class="weui-search-bar" id="searchBar">
    <form class="weui-search-bar__form" id="search-form">
        <div class="weui-search-bar__box">
            <i class="weui-icon-search"></i>
            <input type="search" class="weui-search-bar__input" id="searchInput" placeholder="搜索" name="name" required="" >
            <a href="javascript:searchData();" class="weui-icon-clear" id="searchClear"></a>
        </div>
        <label class="weui-search-bar__label" id="searchText">
            <i class="weui-icon-search"></i>
            <span>搜索</span>
        </label>
        <input type="hidden" name='page' value="1" id="page"/>
    </form>
    <a href="javascript:searchData()" class="mulanbay-search-btn" id="searchData">搜索</a>
</div>
<!--列表数据显示-->
<div id="dataContent"></div>
<!--滚动加载-->
<div class="weui-loadmore" id="loadingSpan">
    <span class="weui-loadmore__tips">加载中...</span>
</div>
<!--编辑页面-->
<div id="edit-popup" class='weui-popup__container popup-bottom'>
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner">
                <a href="javascript:;" class="picker-button close-popup">关闭</a>
                <h1 class="title">身体不适信息</h1>
            </div>
        </div>
        <div class="modal-content">
            <div class="white_bg">
                <form id="edit-form">
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd">
                            <label class="weui-label">疾病<span class="mulanbay-notNull">*</span></label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" placeholder="" name="disease" id="disease">
                        </div>
                        <div class="weui-cell__hd">
                            <a href="javascript:showBANEditTag('disease','/bodyAbnormalRecord/getAbnormalCategoryTree?groupField=disease','疾病症状(表现出的疾病)','DISEASE');"><img src="../../static/image/tag.png" alt="说明"></img></a>
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd">
                            <label class="weui-label">器官<span class="mulanbay-notNull">*</span></label>
                        </div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="text" placeholder="" name="organ" id="organ">
                        </div>
                        <div class="weui-cell__hd">
                            <a href="javascript:showBANEditTag('organ','/bodyAbnormalRecord/getAbnormalCategoryTree?groupField=organ','发病器官','ORGAN');"><img src="../../static/image/tag.png" alt="说明"></img></a>
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd"><label class="weui-label">疼痛等级<span class="mulanbay-notNull">*</span></label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="number" placeholder="数字：0-10" name="painLevel">
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd"><label class="weui-label">重要程度<span class="mulanbay-notNull">*</span></label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="number" placeholder="(0.0-5.0)" name="importantLevel">
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd"><label class="weui-label">发生日期<span class="mulanbay-notNull">*</span></label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" id='occurDate' name="occurDate" type="text" value="">
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd"><label class="weui-label">结束日期<span class="mulanbay-notNull">*</span></label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" id='finishDate' name="finishDate" type="text" value="">
                        </div>
                    </div>
                    <div class="weui-cell mulanbay_select-before">
                        <div class="weui-cell__hd"><label class="weui-label">持续天数<span class="mulanbay-notNull">*</span></label></div>
                        <div class="weui-cell__bd">
                            <input class="weui-input" type="number" placeholder="" name="lastDays">
                        </div>
                    </div>
                    <div class="weui-cells__title"><span class='mulanbay_textarea_title'>备注</span></div>
                    <div class="weui-cells weui-cells_form">
                        <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <textarea class="weui-textarea" placeholder="" rows="3" name="remark"></textarea>
                                <div class="weui-textarea-counter"><span>0</span>/200</div>
                            </div>
                        </div>
                    </div>
                    <input type="text" style="display:none;" name='id' id="id" value=""/>
                </form>
            </div>
            <br>
            <br>
            <a href="javascript:saveData();" class="weui-btn weui-btn_primary weui-footer_fixed-bottom"><label id="edit-button-name">保存</label></a>
        </div>
    </div>
</div>

<!--TAG编辑页面-->
<div id="edit-tag-popup" class='weui-popup__container'>
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner">
                <a href="javascript:$.openPopup('#edit-popup');" class="picker-button close-popup">关闭</a>
                <h1 class="title">标签信息</h1>
            </div>
        </div>
        <div class="modal-content">
            <div class="white_bg">
                <form id="edit-tag-form">
                    <div class="page-hd">
                        <div class="weui-cells__title"><span class='mulanbay_textarea_title'><label id="tagDesc"></label><span class="mulanbay-notNull">*</span></span>
                        </div>
                        <div class="weui-cells weui-cells_form">
                            <div class="weui-cell">
                                <div class="weui-cell__bd">
                                    <input class="weui-input" type="text" placeholder="" name="commonTag" id="commonTag">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="page-bd-15">
                        <div align="center"><label class="mulanbay_notify">(如果在下面标签都没有找到，请手动输入)</label></div>
                        <div class="weui-label-list">
                            *我的常用：
                            <div id="userTagList"></div>
                            <br><br>
                            *系统推荐：
                            <div id="systemTagList"></div>
                        </div>
                    </div>
                    <br>
                    <br>
                    <input type="text" style="display:none;" name='fromEditTagId' id="fromEditTagId" value=""/>
                </form>
            </div>
            <br>
            <br>
            <a href="javascript:saveBANEditTag();" class="weui-btn weui-btn_primary weui-footer_fixed-bottom"><label id="edit-tag-button-name">确定</label></a>
        </div>
    </div>
</div>


<br>
<a href="javascript:showAdd();" class="weui-btn weui-btn_primary weui-footer_fixed-bottom">新增</a>
<script type="text/javascript" src="../../static/include/footer-js.js"></script>
<script>
    $(function() {
        pushRefresh(getData);
        //如果用大写的yyyy-MM-dd，会导致显示值为中文的月份
        $("#occurDate").calendar({dateFormat: 'yyyy-mm-dd'});
        $("#finishDate").calendar({dateFormat: 'yyyy-mm-dd'});
        getData();
        pushStateListener();
    });
    function showBANEditTag(fromId,url,desc,systemTagCode) {
        $('#fromEditTagId').val(fromId);
        showEditTag2(fromId,url,systemTagCode,false);
        $('#commonTag').val($('#'+fromId).val());
        setElementInnerHTML('tagDesc',desc);
    }
    function saveBANEditTag() {
        //这里不是tag
        var fromId = $('#fromEditTagId').val();
        $('#'+fromId).val($('#commonTag').val());
        $.openPopup('#edit-popup') ;
    }
    function addEditTag(tag) {
        $('#commonTag').val(tag);
    }
    function showAdd() {
        $.openPopup('#edit-popup') ;
        initForm();
        clearForm("edit-form");
        var formData = {
            painLevel: 3,
            importantLevel: 3,
            occurDate: getDay(0),
            finishDate: getDay(0),
            lastDays:1
        };
        $('#edit-form').loadJson(formData);
        setElementInnerHTML('edit-button-name','增加');
    }
    function showEdit(id) {
        $.openPopup('#edit-popup') ;
        clearForm("edit-form");
        var url='/bodyAbnormalRecord/get?id='+ id;
        doAjax(null,url,'GET',false,function(data){
            $('#edit-form').loadJson(data);
        });
        setElementInnerHTML('edit-button-name','修改');
    }
    function initForm() {
    }
    function saveData() {
        var postData = form2Json("edit-form");
        var create=false;
        var url='/bodyAbnormalRecord/edit';
        if($("#id").val()==null||$("#id").val()==''){
            url='/bodyAbnormalRecord/create';
            create=true;
        }
        doFormSubmit(postData,url,function(data){
            $.closePopup('#edit-popup') ;
            if(create){
                getData();
                gotoTop();
            }else {
                var hh = createRow(data);
                setElementInnerHTML(getDivId(data.id),hh);
            }
        });
    }
    function showDelete(id) {
        var delUrlPrefix = '/bodyAbnormalRecord/delete';
        commonDeleteByIds(delUrlPrefix,id,function () {
            //searchData();
            //直接把该节点删除
            setElementInnerHTML(getDivId(id),'');
        });
    }
    function searchData() {
        setPage(1);
        getData();
    }
    function getData() {
        var url = '/bodyAbnormalRecord/getData';
        loadListData('search-form','dataContent','page',url,createRow,null);
    }
    function getDivId(id) {
        return 'BodyAbnormalRecord'+id;
    }
    function createRow(rowData) {
        var html='';
        html+='<div id="'+getDivId(rowData.id)+'">';
        html+='<div class="weui-form-preview">';
        html+='    <a class="weui-cell  weui-cell_access weui-cell_example" href="javascript:showEdit('+rowData.id+');">\n';
        var pic = '<img src="../../static/image/sick.png">';
        html+='        <div class="weui-cell__hd">'+pic+'</div>\n';
        html+='        <div class="weui-cell__bd">\n';
        html+='<label class="weui-form-preview__label mulanbay-dark-font">'+rowData.disease+'</label>';
        html+='        </div>\n';
        var ss =''+rowData.organ;
        html+='        <div class="weui-cell__ft">'+ss+'</div>\n';
        html+='    </a>\n';
        html+='    <div class="weui-form-preview__bd">\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">发生日期</label>\n';
        html+='            <span class="weui-form-preview__value">'+rowData.occurDate+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">结束日期</label>\n';
        html+='            <span class="weui-form-preview__value">'+rowData.finishDate+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">持续天数</label>\n';
        html+='            <span class="weui-form-preview__value">'+rowData.lastDays+'</span>\n';
        html+='        </div>\n';
        html+='        <div class="weui-form-preview__item">\n';
        html+='            <label class="weui-form-preview__label">备注</label>\n';
        var rr='';
        if(rowData.remark){
            rr= rowData.remark;
        }
        html+='            <span class="weui-form-preview__value">'+rr+'</span>\n';
        html+='        </div>\n';
        html+='    </div>\n';
        html+='    <div class="weui-form-preview__ft">\n';
        html+='        <a class="weui-form-preview__btn weui-form-preview__btn_delete" href="javascript:showDelete('+rowData.id+');">删除</a>\n';
        html+='    </div>\n';
        html+='</div>\n';
        html+='</div>\n';
        html+='<br>\n';
        return html;
    }
</script>
</body>
</html>